package global

import (
	"reflect"
	"strings"
)

func IsInstanceOf(objectPtr, typePtr interface{}) bool {
	return reflect.TypeOf(objectPtr) == reflect.TypeOf(typePtr)
}
func Supplier(any) {

}

func HeadName(source string) string {
	index := strings.LastIndex(source, ".")
	return substring(source, 0, index)
}

func SimpleName(i any) string {
	source := reflect.TypeOf(i).String()
	index := strings.LastIndex(source, ".") + 1
	return substring(source, index, len(source))
}

func substring(source string, start int, end int) string {
	var r = []rune(source)
	length := len(r)

	if start < 0 || end > length || start > end {
		return ""
	}

	if start == 0 && end == length {
		return source
	}

	return string(r[start:end])
}
